﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using INSTA.BankApplication.Engine;
using NUnit.Framework;


namespace INSTA.BankApplication.Engine.Tests
{
    [TestFixture]
    public class Test_AccountFactory
    {
        AccountBase     _account;
        Customer        _customer;

        [SetUp]
        public void SetUp()
        {
            _customer = new Customer();
        }


        [Test]
        public void Test_Method_Create_ForStandard_Min()
        {
            _account = Bank.Instance().CreateAccount(_customer, AccountFactory.MIN_DEPOSIT_STANDARD);
                        
            // avec syntaxe générique..
            Assert.IsInstanceOf<StandardAccount>(_account);

            // equivalent :
            //Assert.IsTrue(account.GetType() == typeof(StandardAccount));

        }

        [Test]
        public void Test_Method_Create_ForStandard_Max()
        {
            _account = Bank.Instance().CreateAccount(_customer, AccountFactory.MAX_DEPOSIT_STANDARD - 1);

            // avec syntaxe générique..
            Assert.IsInstanceOf<StandardAccount>(_account);

        }





        [Test]
        public void Test_Method_Create_ForSilver_Min()
        {
            _account = Bank.Instance().CreateAccount(_customer, AccountFactory.MIN_DEPOSIT_SILVER);

            // avec syntaxe générique..
            Assert.IsInstanceOf<SilverAccount>(_account);

            // equivalent :
            //Assert.IsTrue(account.GetType() == typeof(SilverAccount));

        }

        [Test]
        public void Test_Method_Create_ForSilver_Max()
        {
            _account = Bank.Instance().CreateAccount(_customer, AccountFactory.MAX_DEPOSIT_SILVER - 1);

            // avec syntaxe générique..
            Assert.IsInstanceOf<SilverAccount>(_account);

        }



        [Test]
        public void Test_Method_Create_ForGold_Min()
        {
            _account = Bank.Instance().CreateAccount(_customer, AccountFactory.MIN_DEPOSIT_GOLD);

            // avec syntaxe générique..
            Assert.IsInstanceOf<GoldAccount>(_account);

        }


        [Test]
        public void Test_Method_Create_ForNegativeDeposit_1()
        {
            Exception exception = null;

            try
            {
                _account = Bank.Instance().CreateAccount(_customer, -1);
            }
            catch (ArgumentException ex)
            {
                exception = ex;
            }

            Assert.IsInstanceOf<ArgumentException>(exception);
        }

        [Test]
        public void Test_Method_Create_ForNegativeDeposit_2()
        {
            Assert.Throws<ArgumentException>(() => Bank.Instance().CreateAccount(_customer, -1));
            
        }


        //[Test]
        //[ExpectedException(typeof(ArgumentException))]
        //public void Test_Method_Create_ForNegativeDeposit_3()
        //{
        //    Bank.Instance().CreateAccount(_customer, -1);
        //}




















    }
}
